package com.xhwy.mapper;

import com.xhwy.entity.ShoppingCart;
import com.xhwy.param.ShoppingCartSaveParam;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface ShoppingCartMapper {

    /**
     * 根据用户id和商品id查询购物车
     * @param shoppingCartSaveParam
     * @return
     */
    ShoppingCart getByUserIdAndProductId(ShoppingCartSaveParam shoppingCartSaveParam);

    /**
     * 添加购物车
     * @param shoppingCart
     * @return
     */
    int add(ShoppingCart shoppingCart);

    /**
     * 修改购物车
     * @param shoppingCart
     * @return
     */
    int update(ShoppingCart shoppingCart);
    /**
     * 根据用户id获取购物车数据
     * @param userId
     * @return
     */
    List<ShoppingCart> getByUserId(Integer userId);

    /**
     * 根据用户id和商品id删除购物车数据
     * @param shoppingCart
     * @return
     */
    int delete(ShoppingCart shoppingCart);

    /**
     * 批量删除购物车数据
     * @param shoppingCartIds
     * @return
     */
    int batchDelete(List<Integer> shoppingCartIds);
}
